home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr23
/
chansw53.zip
/
CHAINSAW.TUT
< prev
next >
Wrap
Text File
|
1993-05-24
|
16KB
|
464 lines
CHAINSAW
Tutorial and Examples
Copyright 1992, Ted Davis
CHAINSAW TUTORIAL
This tutorial will take you through most of the modes and
some of the message patterns, one or two steps at a time.
It will also provide examples of both command line and batch
file operation.
For learning purposes, we will use a floppy disk.
The lessons assume drive 'A:', if you are using another
drive, just replace the 'A:' or 'a:' part of the path with
the drive you are using. This tutorial assumes that you
have read the manual, or at least scanned it and found the
default password. If you don't know the password, you can't
make the program work. CHAINSAW must not be on the scratch
disk, it must be on a different drive, we will assume 'C:'.
First we will see what happens if you don't get the
command tail right:
Change the default drive and directory to the one that has
CHAINSAW in it or make sure CHAINSAW is in the path;
invoke CHAINSAW with no command tail -
CHAINSAW <Enter>
which should get you the barf message.
Now we will try something more useful, cleaning out a \temp
directory:
Prepare a scratch disk by inserting a
blank, formatted diskette in the drive you wish to use and
invoking the MKSCRTCH batch file -
MKSCRTCH A 1 <Enter>
for the 'A:' drive (or B, or C, or D, etc.).
The batch file will create a directory tree and copy
itself to each directory (with several different names). Use
DIR, DOSSHELL, or some other utility to look at the scratch
disk - you should find 25 files in the root and three
subdirectories and sub-sub (etc.) directories.
Now for the test - invoke CHAINSAW with its default
switches and a:\temp as the target directory with this
command line, replacing {password} with the default password
given in the manual.
CHAINSAW a:\temp {password} <Enter>
You should have gotten this response:
Now take a look at the directory structure - there
should be nothing left except the root and its files, \foo
and its files, and \temp and its files.
1
CHAINSAW TUTORIAL
But maybe you want the \temp directory completely
empty, instead of just devoid of subdirectories. Rebuild
the scratch disk with the same MKSCRTCH command and try this
CHAINSAW a:\temp {password} /f <Enter>
(making sure that the 'f' is lower case).
The summary should show five more files deleted. Now
look at the \temp directory and note that it is completely
empty of both files and subdirectories. Note also that the
root and \foo directories are completely untouched.
For even more through cleaning, try
CHAINSAW a:\temp {password} /g <Enter>
and note that now the entire \temp directory is gone. You
could try that again after running MKSCRTCH again but the
effect is the same. Note also the above 'g' switch must
be lower case.
Now lets add some list messages. To save time, we
will combine that with the /r switch. Without rebuilding
the scratch disk (it still has ten files in two
directories), we invoke the program this way -
CHAINSAW a:\ {password} /frdl <Enter>
which enables file removal from the given directory,
operation in the root directory, and listing of both file
and directory deletions. Note that all switches are lower
case.
DIR a: now shows that only the volume label is left
on the disk.
It isn't always that easy; sometimes there are
hidden, read-only, or system files to be removed. Invoke
MKSCRTCH again to rebuild the scratch disk, this time with
some of the files protected -
MKSCRTCH A 2 <Enter>
which marks one file in each directory read-only, one
hidden, and one both hidden and read-only.
Repeat the last invocation of CHAINSAW (/frdl) only
this time, redirect the output to a file. For the example
we will assume that the destination file is
c:\temp\chainsaw.lst. The command line is -
CHAINSAW a:\ {password} /f r,d;l > c:\temp\chainsaw.lst <Enter>
2
CHAINSAW TUTORIAL
which also illustrates alternate ways of entering the
switches. Now use your word processor or editor to look at
the list file and also look at the disk. You should note
that the directory structure is still intact and that each
directory shows one file (the read-only one) but that the
total files line in the DIR response includes two more that
don't show. The list file contains a lot of failure
messages: one for each protected file and one for each sub
directory. Lets get rid of the leftovers and wipe the disk
clean.
CHAINSAW a:\ {password} /frdlp <Enter>
Note that the program now leaves the disk blank,
except for the volume label, and the list now shows the
protected files and all subdirectories as successfully
removed. The unprotected files were removed on the
previous pass.
Since it isn't feasible to demonstrate the network
drive protection switch on a floppy, we will just skip it.
If you have a network, you could set up a dummy directory
and files and use the /n switch to enable their removal.
Just be careful to specify the dummy directory as the base
and use the /f or /g switches.
So much for the mode control switches, now lets try a
few variations of the message control switches. Let's also
play around with using CHAINSAW from a batch file. The
file CHTST.BAT contains the call to CHAINSAW, less the
password. It also invokes MKSCRTCH for drive A:. If you
are using some other drive for the scratch disk, use a text
editor to change 'A:' in the CHAINSAW command tail and
the 'A' in the MKSCRTCH call to whatever drive you are
using. Also change the c:\temp\chainsaw.lst redirection to
whatever you want. The modified file must be in ASCII format.
In any case, examine the batch file to see what the command
tails are for the various modes. The batch file uses the
DOS batch file CALL command. If your version of DOS does
not support it, change CALL to COMMAND /C
CHTST 1 {password} <Enter>
displays the copyright and summary on the screen and sends
the list of deleted files to c:\temp\chainsaw.lst. It uses
the switch string /freDL, 'fr' to enable removing files from
the root, 'e' to send everything to STDERR (the screen), and
'DL' to enable listing and send the lists to STDOUT
(redirected to c:\temp\chainsaw.lst). This shows that later
switches ('D' and 'L') can override earlier ones ('e').
CHTST 2 {password} <Enter> shows what happens if
there are removal errors: the list of removals still goes to
the file, but the list of failures goes to the screen.
3
CHAINSAW TUTORIAL
CHTST 3 {password} <Enter> uses a variation of the
'e' switch ('eo') to send the failure messages to the file
also. Here is a bit of a trick that you can use to get the
successes and failures in separate files. The 'E' switch
could be used instead of 'eo' but would send the copyright
and summary messages to the file also. Ignore the DOS error
messages: DOS is trying to copy over read-only files and
reset the attributes of hidden files left over from CHTST 2.
FIND "***" c:\temp\chainsaw.lst > a:\bad.lst <Enter>
FIND "..." c:\temp\chainsaw.lst > a:\ok.lst <Enter>
will create two files on the scratch disk with the list of
deletions in ok.lst and the list of failures in bad.lst.
Let's get fancy. If you do not have a copy of some
version of AWK that accepts standard AWK scripts, you will
need to get one to complete this example. I recommend GAWK,
which is freeware from the Free Software Foundation. There
are several AWK scripts in the CHAINSAW package. We will
use SPLITLST.AWK to send the success and failure lists to
separate files. The script creates its destination files in
the default directory unless you tell it otherwise. For the
example, we will accept all its defaults.
Rebuild the scratch disk with -
MKSCRTCH A 2 <Enter>
Then -
CHAINSAW a:\ {password} /frEDL | AWK -f splitlst.awk <Enter>
creates the two files DONE.LOG and FAIL.LOG for the success
and failure messages respectively. You could also use
/frb | AWK -f splitlst.awk > other.log to create three
files: one for success messages, one for failure messages,
and one (OTHER.LOG) for all the other messages. The 'b'
switch sends all messages to STDOUT, and AWK then splits
STDOUT into three streams, two to named files and the
residue back to STDOUT for further processing or
redirection.
If you don't know about AWK, you should. It is one
of the most difficult, but also most useful, utilities to
be had anywhere, at any price. Some versions are even free.
The example script only hints at its power.
By now, you should have a fair idea of what CHAINSAW
is and what it can do. Let's move on to setting up your own
custom version. You will certainly want to change the
password, or even eliminate it and in all likelihood, you
will want the default switches to be somewhat different.
4
CHAINSAW TUTORIAL
First, we will remove the password, then install a
new one.
CHAINSAW /Z {password} <Enter>
removes the default password. The program is now as open as
FORMAT to use by any fool who comes along and wants to play
games with your machine. It is also somewhat easier for you
to use. The choice is yours.
We do not have to remove the password to install
another, that just showed how to do it. Now install a
temporary password for practice. Use "White.Rabbit".
CHAINSAW \zWhite.Rabbit <Enter>
Call CHAINSAW to test it -
CHAINSAW a:\ White.Rabbit -fr <Enter>
Note that either '/' or '-' is acceptable for the
switch marker.
You should get a report that the program did nothing.
You should not get the bad password message.
Now try introducing an error, omitting the period -
CHAINSAW a:\ WhiteRabbit -fr <Enter>
You should have gotten the bad password message.
Now select a personal password, up to 15 characters,
not including <, >, |, space, or tab, unless within a
quoted string. Write it down and put it somewhere safe.
Now install it -
CHAINSAW /z{new password} White.Rabbit <Enter>
and repeat the above tests to be sure it works correctly.
If you make a mistake that you cannot remedy, unzip another
copy of CHAINSAW.EXE from the distribution package and start
over.
Last, but not least, we practice changing default
switches. The program comes configured for safety rather
than convenience. For practice, lets make the defaults
/BGNprfSW instead of /BGNPRsw -
CHAINSAW /a/BGNprfSW {password} <Enter>
Now
MKSCRTCH A 2 <Enter>
5
CHAINSAW TUTORIAL
CHAINSAW a:\ {password} <Enter>
and experience a moment of panic - no messages at all, but
the scratch disk is cleaned off completely.
MKSCRTCH A 2 <Enter>
CHAINSAW a:\ {password} /w <Enter>
brings back the messages by overriding the default 'W' with
the given 'w' switch.
Restore the defaults -
CHAINSAW /A {password} <Enter>
You may eventually want to set up several versions of
the program with different defaults. That works fine. You
can rename the program and have several versions with
different names in the same directory with no problems or
interference; each version knows its own name. You can also
have different versions with the same name in separate
directories; the program also knows where the copy in use
lives, as well as its name.
Thus ends the tutorial; I hope it was enough to get
you started and to show the most important aspects of the
program.
T.E.D. 1/12/92
6